/*
 * Copyright (c) 2009, Servoy-stuff
 * 
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 * http://www.fsf.org/licensing/licenses/lgpl.txt
 */
package net.stuff.servoy.beans.calendar.swing;

import javax.swing.SpinnerNumberModel;

/**
 * A specialized spinner model wich will wrap when reaching min or max values
 * 
 * @version 1.2 - 2010-03-01 - Servoy 5+
 * @version 1.0.1 - 2009-06-01 - Added Time controls
 * @author servoy-stuff
 * http://www.servoy-stuff.net/
 */
public class WrapSpinnerNumberModel extends SpinnerNumberModel {

	private static final long serialVersionUID = 1L;
	
	

	/**
	 * 
	 */
	public WrapSpinnerNumberModel() {
		super();
	}

	/**
	 * @param value
	 * @param minimum
	 * @param maximum
	 * @param stepSize
	 */
	public WrapSpinnerNumberModel(double value, double minimum, double maximum,
			double stepSize) {
		super(value, minimum, maximum, stepSize);
	}

	/**
	 * @param value
	 * @param minimum
	 * @param maximum
	 * @param stepSize
	 */
	public WrapSpinnerNumberModel(int value, int minimum, int maximum,
			int stepSize) {
		super(value, minimum, maximum, stepSize);
	}

	/**
	 * @param value
	 * @param minimum
	 * @param maximum
	 * @param stepSize
	 */
	public WrapSpinnerNumberModel(Number value, Comparable minimum,
			Comparable maximum, Number stepSize) {
		super(value, minimum, maximum, stepSize);
	}
	

	/* (non-Javadoc)
	 * @see javax.swing.SpinnerNumberModel#getNextValue()
	 */
	@Override
	public Object getNextValue() {
		Object o = super.getNextValue();
		if (o == null) {
			return getMinimum();
		}
		return super.getNextValue();
	}

	/* (non-Javadoc)
	 * @see javax.swing.SpinnerNumberModel#getPreviousValue()
	 */
	@Override
	public Object getPreviousValue() {
		Object o = super.getPreviousValue();
		if (o == null) {
			return getMaximum();
		}
		return super.getPreviousValue();
	}
	
	

}
